using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using Common.Enum;

namespace SettingsView.View
{
	public class ERowSpaceModeBooleanConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value != null && value != DependencyProperty.UnsetValue && parameter != null && Enum.IsDefined(value.GetType(), parameter))
			{
				object obj = Enum.Parse(value.GetType(), parameter.ToString());
				return obj.Equals(value);
			}
			return false;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value != null && value != DependencyProperty.UnsetValue && value is bool && (bool)value)
			{
				return ERowSpaceMode.Sample;
			}
			return ERowSpaceMode.Null;
		}
	}
}
